package com.rms.hkpc.presenter;


import com.google.gson.reflect.TypeToken;
import com.rms.hkpc.apiresult.ApiResultData;
import com.rms.hkpc.db.dto.WorksOrderDto;
import com.rms.hkpc.model.listener.OnResultListener;
import com.rms.hkpc.model.RecordsDetailModel;
import com.rms.hkpc.view.IRecordsDetailView;

public class RecordsDetailPresenter extends BasePresenter<IRecordsDetailView> {
    private RecordsDetailModel recordsDetailModel = new RecordsDetailModel();

    public void getRecords(String id) {
        recordsDetailModel.getRecords(id, new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onGetDataSuccess((ApiResultData<WorksOrderDto>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onGetDataFails(e);
                }
            }
        }, new TypeToken<ApiResultData<WorksOrderDto>>() {
        }.getType());
    }
}
